﻿using System;

namespace cSharpHomework3_2
{
    class Program
    {
        static void Main(string[] args)
        {
            Ring ring = new Ring();
            ring.ring += (RingEventHandler, EventArgs) => { Console.WriteLine("ring"); };
            ring.Tick += (RingEventHandler, EventArgs) => { Console.WriteLine("Tick"); };
            ring.alarm();
            ring.tick();
        }

        public delegate void RingEventHandler(Ring ring, EventArgs e);
        public delegate void TickEventHandler(Ring ring, EventArgs e);

        public class Ring
        {
            private RingEventHandler ringEventHandler;
            private TickEventHandler tickEventHandler;
            public event RingEventHandler ring
            {
                add
                {
                    this.ringEventHandler += value;

                }
                remove
                {
                    this.ringEventHandler -= value;
                }
            }
            public event TickEventHandler Tick
            {
                add
                {
                    this.tickEventHandler += value;

                }
                remove
                {
                    this.tickEventHandler -= value;
                }
            }

            public void alarm()
            {
                this.ringEventHandler.Invoke(this, null);
            }

            public void tick()
            {
                this.tickEventHandler.Invoke(this, null);
            }
        }

    }
}
